home *** CD-ROM | disk | FTP | other *** search
- program GimmieaFortune;
- {
- Note:
- This program is in the Public Domain, it is free, and should remain so.
- If you would like to make a contribution,
- it would be much appreciated:
-
- Write another program and give it away.
-
-
- Program : FORTUNE.COM
- Author : Grant Gouldon
- Date : 5/24/85
- Source : FORTUNE.PAS compiled by Turbo Pascal 3.0
- Purpose :
-
- This program will deliver you a fortune out of a file of fortune cookies
- i.e. FORTUNE.COK
-
- The file of fortunes MUST have as its first line the number of records
- to follow. This is an easy way of telling the program how big the file
- is, without having to go the route of fixed length records (which would
- allow both random access, and implicitly knowing the file size, but
- would make for a much much bigger file).
-
- Add more fortunes !
-
- (Just keep that record count updated)
-
- Once we know how big the file is,
- we pick a random number n < file size,
- skip n records, then read and print the next one.
-
- If the user gives a numeric argument to fortune, he or she will
- get that many fortunes. If the argument is non-numeric, some
- help text will be displayed.
-
- }
-
-
- Var
- FilVar: text;
- Cookie: string[255];
- NumRecs,
- N,
- J,
- HowMany,
- Ecode: integer;
-
- begin
- Assign(FilVar,'FORTUNE.COK');
- if ParamCount = 0 then
- HowMany := 1
- else
- begin
- Val(ParamStr(1),HowMany,Ecode);
- if Ecode <> 0 then
- begin
- Writeln('If you come here seeking Fame and Fortune,');
- Writeln('I must tell you that task is too vast for me.');
- Writeln('but ...');
- Writeln('I can do something half vast:');
- Writeln('I will give you your Fortune.');
- Writeln(' ');
- Writeln(' ');
- Writeln('If you say FORTUNE 4 I will give you 4 fortunes.');
- Exit
- end;
- end;
- for J := 1 to HowMany do
- begin
- Reset(FilVar);
- Readln(FilVar,NumRecs);
- for N := 1 to Random(NumRecs) do
- begin
- Readln(filvar);
- end;
- Readln(FilVar,Cookie);
- Writeln(Cookie);
- end;
- end.